<template>
  <div class="user-detail-container">
    <el-card>
      <h2>员工详情</h2>
      <el-descriptions :title="user.name" :column="2" border>
        <el-descriptions-item label="姓名">{{ user.name }}</el-descriptions-item>
        <el-descriptions-item label="部门">{{ user.department }}</el-descriptions-item>
        <el-descriptions-item label="职位">{{ user.position }}</el-descriptions-item>
        <el-descriptions-item label="电话">{{ user.phone }}</el-descriptions-item>
        <el-descriptions-item label="邮箱">{{ user.email }}</el-descriptions-item>
        <el-descriptions-item label="状态">
          <el-tag :type="user.status === '在职' ? 'success' : 'info'">{{ user.status }}</el-tag>
        </el-descriptions-item>
      </el-descriptions>
      <el-button style="margin-top: 20px;" @click="$router.back()">返回</el-button>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'UserDetail',
  props: ['id'],
  data() {
    return {
      user: {
        name: '',
        department: '',
        position: '',
        phone: '',
        email: '',
        status: ''
      }
    }
  },
  created() {
    this.fetchUser()
  },
  methods: {
    fetchUser() {
      // 模拟获取员工详情数据
      // 实际开发中可通过id请求后端API
      const mock = {
        1: {
          name: '张三',
          department: '技术部',
          position: '经理',
          phone: '13800138000',
          email: 'zhangsan@example.com',
          status: '在职'
        },
        2: {
          name: '李四',
          department: '人事部',
          position: '员工',
          phone: '13800138001',
          email: 'lisi@example.com',
          status: '在职'
        }
      }
      this.user = mock[this.id] || {
        name: '未知',
        department: '-',
        position: '-',
        phone: '-',
        email: '-',
        status: '-'
      }
    }
  }
}
</script>

<style scoped>
.user-detail-container {
  padding: 30px;
  max-width: 600px;
  margin: 0 auto;
}
</style> 